import type { ConsultType } from '@/enums'
import type { PartialConsult, Illness } from '@/types/consult'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useConsultStore = defineStore(
  'consult',
  () => {
    // 问诊记录 // 应该传入可填可不填的类型
    const consult = ref<PartialConsult>({})
    // 修改问诊类型
    function setType(type: ConsultType) {
      consult.value.type = type
      console.log(consult.value)
    }
    // 修改快速问诊类型 有三甲和普通
    function setIllnessType(illnessType: 0 | 1) {
      consult.value.illnessType = illnessType
    }
    // 修改科室
    function setDepId(depId: string) {
      consult.value.depId = depId
    }
    // 图文问诊，病情描述相关信息
    function setIllness(illness: Illness) {
      consult.value.illnessDesc = illness.illnessDesc
      consult.value.illnessTime = illness.illnessTime
      consult.value.consultFlag = illness.consultFlag
      consult.value.pictures = illness.pictures
    }
    // 选择患者id
    function setPatient(id: string) {
      consult.value.patientId = id
    }
    // 修改优惠劵
    function setCoupon(id: string) {
      consult.value.couponId = id
    }
    // 清除记录
    const clear = () => {
      consult.value = {}
    }
    return {
      consult,
      setType,
      setIllnessType,
      setDepId,
      setIllness,
      setPatient,
      setCoupon,
      clear
    }
  },
  {
    persist: true
  }
)
